const { Article } = require('../../model/article');
const { Comment } = require('../../model/comment');
module.exports = async(req, res) => {
        const id = req.query.id;

        req.app.locals.currentLink = 'article';

        // 查询文章信息
        let articleData = await Article.find({ _id: id }).populate('author');
        let str = JSON.stringify(articleData);
        let json = JSON.parse(str);
        

        // 查询文章评论信息
        let commentData = await Comment.find({ aid: id }).populate('uid');
        let str2 = JSON.stringify(commentData);
        let json2 = JSON.parse(str2);
        console.log(json2)

        res.render('home/article', {
                articleData: json[0],
                commentData: json2
        });
    
}